/**
 * Project Name:wealth-common
 * File Name:RandomNumUtil.java
 * Package Name:com.wealth.common.utils
 * Date:2016年4月20日下午2:08:16
 * Copyright (c) 2016,  All Rights Reserved.
 *
*/

package utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.UUID;

/**
 * ClassName:RandomNumUtil <br/>
 * Function: 随机数工具类. <br/>
 * Date: 2016年4月20日 下午2:08:16 <br/>
 * 
 * @author i1093108915@yeah.net
 * @version
 * @since JDK 1.6
 * @see
 */
public class RandomNumUtil {

	/**
	 * generateSMSCode:(6位短信验证码). <br/>
	 *
	 * @author i1093108915@yeah.net
	 * @return
	 * @since JDK 1.6
	 */
	public static String generateRandomCode() {
		String str = "";
		str += (int) (Math.random() * 9 + 1);
		for (int i = 0; i < 5; i++) {
			str += (int) (Math.random() * 10);
		}
		int num = Integer.parseInt(str);
		return String.valueOf(num);
	}

	/**
	 * generateP2PUserId:(生成用户标识ID). <br/>
	 * 
	 * @author i1093108915@yeah.net
	 * @return
	 * @since JDK 1.6
	 */
	public static String generateUserCode() {
		SimpleDateFormat txt = new SimpleDateFormat("yyyyMMdd");
		System.out.println(txt.format(new Date()));
		long ymd = Long.valueOf(txt.format(new Date()));
		long current = System.currentTimeMillis();
		return new StringBuilder().append(ymd%9999).append(current%99999999).toString();
	}

	public static void main(String[] args) {
		// generateRandomCode();
//		String aString = generateUserCode();
		for (int i = 0; i < 30; i++) {
			System.out.println(getUUID());
			
		}
	}
	
	public static String getUUID() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}
}
